﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model.Bas;

namespace nERP.Model.Bas
{
    /// <summary>
    /// 单据编码规则
    /// </summary>
	[Table("CodingRule")]

    [Display(Name = "_Model.CodingRule")]
    public class CodingRule : BasePoco,IPersistPoco, ITenant
    {
        [Display(Name = "_Model._CodingRule._CodingList")]
        [Comment("单据编码规则主表")]
        [NotMapped]
        public CodingList CodingList { get; set; }
        [Display(Name = "_Model._CodingRule._CodingList")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("单据编码规则主表")]
        public string CodingListId { get; set; }
        [Display(Name = "_Model._CodingRule._Seq")]
        [Comment("序号")]
        [Range(1,10,ErrorMessage="Validate.{0}range{1}{2}")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public int? Seq { get; set; }
        [Display(Name = "_Model._CodingRule._CodeRule")]
        [Comment("规则")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public CodeRuleEnum? CodeRule { get; set; }
        [Display(Name = "_Model._CodingRule._FixedValue")]
        [StringLength(16, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("固定值")]
        public string FixedValue { get; set; }
        [Display(Name = "_Model._CodingRule._FixedRule")]
        [Comment("规则值")]
        public FixedEnum? FixedRule { get; set; }
        [Display(Name = "_Model._CodingRule._GlideLen")]
        [Comment("流水号长度")]
        [Range(1,10,ErrorMessage="Validate.{0}range{1}{2}")]
        public int? GlideLen { get; set; }
        [Display(Name = "_Model._CodingRule._StartNumber")]
        [Comment("流水号起始值")]
        [Range(1,999999999,ErrorMessage="Validate.{0}range{1}")]
        public int? StartNumber { get; set; }
        [Display(Name = "_Model._CodingRule._GlideStep")]
        [Comment("递增步长")]
        [Range(1,999999999,ErrorMessage="Validate.{0}range{1}")]
        public int? GlideStep { get; set; }
        [Display(Name = "_Model._CodingRule._Glide")]
        [StringLength(16, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("流水号补位码")]
        public string Glide { get; set; }
        [Display(Name = "_Model._CodingRule._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

    }

}
